package com.atguigu.gulimall.cart.vo;

import lombok.Builder;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * @DESCRIPTION: 购物项
 * @author: zr
 * @DATE: 2023/1/15 22:46
 */
@Data
public class CartItemVo {
    /**
     * 商品Id
     */
    private Long skuId;
    private Boolean check = true;
    /**
     * 商品标题
     */
    private String title;
    /**
     * 商品默认图片
     */
    private String image;
    private List<String> skuAttr;
    /**
     * 价格
     */
    private BigDecimal price;
    /**
     * 数量
     */
    private Integer count;
    /**
     * 总价
     */
    private BigDecimal totalPrice;

    public BigDecimal getTotalPrice() {
        // 防止精度丢失
        return this.price.multiply(new BigDecimal(this.getCount() + ""));
    }
}
